﻿using Autofac;
using Autofac.Builder;
using Autofac.Core;
using MyFileView.Shard.Repository;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFileView.Core.Repository
{
    public class RegisterSqlSugar
    {
        public static void AddSqlSugar(ContainerBuilder containerBuilder, string conn)
        {
            SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = conn,
                DbType = DbType.Sqlite,
                IsAutoCloseConnection = true
            });
            containerBuilder.Register<ISqlSugarClient>(x => Db);
            containerBuilder.RegisterGeneric(typeof(MyFileViewRepository<>)).As(typeof(IMyFileViewRepository<>)).AsImplementedInterfaces().InstancePerLifetimeScope();
        }
    }
}
